import { FormInstance } from 'antd';
import React from 'react';
import { Dispatch } from 'react';

/** 申请页面上下文类型 */
export interface IApplyContextAPI {
  styleFixCls: string;
  curRes: Record<string, any>;
  locationID: string;
  applyDispatch: Dispatch<any>;
  pageType: string;
  delPathName: string;
  oldApplyInfo: Record<string, any>;
  applyForm: FormInstance | any;
  reloadDetail: () => void;
  applyDetailInfo: Record<string, any>;
  setInvalidState: (res: Record<string, any>) => void;
  invalidState: Record<string, any>;
  setOAMessageRun: (res: Record<string, any>) => any;
  taskId: string;
}

/** 申请管理上下文 */
const INIT_APPLYCONTEXT_VALUE: IApplyContextAPI = {
  styleFixCls: '',
  curRes: {},
  locationID: '',
  applyDispatch: () => {},
  pageType: '',
  delPathName: '',
  oldApplyInfo: {},
  applyForm: {},
  reloadDetail: () => {},
  applyDetailInfo: {},
  setInvalidState: () => {},
  invalidState: {},
  setOAMessageRun: () => {},
  taskId: '',
};

const ApplyControllerContext = React.createContext<IApplyContextAPI>(INIT_APPLYCONTEXT_VALUE);

export { ApplyControllerContext };
